class Solution {
public:
    int hIndex(vector<int>& citations) {
        int Size = citations.size();
        int filenum = 0;
        int citenum = 0;
        int maxcite = 0;
        for (filenum = 1; filenum <= Size; filenum++)
        {
            maxcite = 0;
            for (auto cite : citations)
            {
                if (cite >= filenum)
                {
                    maxcite++;
                }
            }
            if (maxcite >= filenum)
            {
                citenum = filenum;
            }
            else
            {
                break;
            }
        }
        return citenum;
    }
};